Skip to content

Add eth_getCode support to prover - #5364

Merged
wemeetagain merged 6 commits into
unstablefrom
nh/prover-get-code
Apr 19, 2023
Merged

Add eth_getCode support to prover#5364
wemeetagain merged 6 commits into
unstablefrom
nh/prover-get-code

Conversation

@nazarhussain

Copy link
Copy Markdown
Contributor

Motivation

Make the @lodestar/prover more feature rich.

Description

  • Add support for eth_getCode.
  • Add structure to add more unit test case.

Closes #4706

Steps to test or reproduce

  • Run all tests.

@nazarhussain
nazarhussain requested a review from a team as a code owner April 14, 2023 14:33
@nazarhussain nazarhussain self-assigned this Apr 14, 2023
if (verifiedHandler !== undefined) {
logger.verbose("Verified request handler found", {method: payload.method});
return verifiedHandler({payload, handler, proofProvider, logger});
return verifiedHandler({payload, handler, proofProvider, logger, network});

Check failure

Code scanning / CodeQL

Unvalidated dynamic method call

Invocation of method with [user-controlled](1) name may dispatch to unexpected target and cause an exception.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

false positive

@github-actions

github-actions Bot commented Apr 14, 2023

Copy link
Copy Markdown
Contributor

Performance Report

鉁旓笍 no performance regression detected

Full benchmark results
Benchmark suite Current: 843cce0 Previous: 42ecf97 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 1.0107 ms/op 879.43 us/op 1.15
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 48.949 us/op 44.016 us/op 1.11
BLS verify - blst-native 1.2341 ms/op 1.1868 ms/op 1.04
BLS verifyMultipleSignatures 3 - blst-native 2.4953 ms/op 2.4144 ms/op 1.03
BLS verifyMultipleSignatures 8 - blst-native 5.3316 ms/op 5.1871 ms/op 1.03
BLS verifyMultipleSignatures 32 - blst-native 19.360 ms/op 18.766 ms/op 1.03
BLS aggregatePubkeys 32 - blst-native 26.326 us/op 25.342 us/op 1.04
BLS aggregatePubkeys 128 - blst-native 101.41 us/op 97.819 us/op 1.04
getAttestationsForBlock 59.811 ms/op 51.986 ms/op 1.15
isKnown best case - 1 super set check 255.00 ns/op 255.00 ns/op 1.00
isKnown normal case - 2 super set checks 251.00 ns/op 249.00 ns/op 1.01
isKnown worse case - 16 super set checks 248.00 ns/op 250.00 ns/op 0.99
CheckpointStateCache - add get delete 4.9600 us/op 4.7990 us/op 1.03
validate gossip signedAggregateAndProof - struct 2.7663 ms/op 2.6813 ms/op 1.03
validate gossip attestation - struct 1.3621 ms/op 1.2911 ms/op 1.06
pickEth1Vote - no votes 1.4021 ms/op 1.2075 ms/op 1.16
pickEth1Vote - max votes 11.125 ms/op 10.178 ms/op 1.09
pickEth1Vote - Eth1Data hashTreeRoot value x2048 9.2609 ms/op 8.7238 ms/op 1.06
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 16.187 ms/op 14.579 ms/op 1.11
pickEth1Vote - Eth1Data fastSerialize value x2048 768.76 us/op 617.60 us/op 1.24
pickEth1Vote - Eth1Data fastSerialize tree x2048 6.8297 ms/op 7.7105 ms/op 0.89
bytes32 toHexString 535.00 ns/op 473.00 ns/op 1.13
bytes32 Buffer.toString(hex) 349.00 ns/op 342.00 ns/op 1.02
bytes32 Buffer.toString(hex) from Uint8Array 568.00 ns/op 553.00 ns/op 1.03
bytes32 Buffer.toString(hex) + 0x 350.00 ns/op 345.00 ns/op 1.01
Object access 1 prop 0.17300 ns/op 0.15700 ns/op 1.10
Map access 1 prop 0.15900 ns/op 0.15200 ns/op 1.05
Object get x1000 7.1350 ns/op 6.2530 ns/op 1.14
Map get x1000 0.59500 ns/op 0.58700 ns/op 1.01
Object set x1000 55.188 ns/op 49.909 ns/op 1.11
Map set x1000 45.359 ns/op 41.890 ns/op 1.08
Return object 10000 times 0.24240 ns/op 0.22720 ns/op 1.07
Throw Error 10000 times 4.3005 us/op 3.9663 us/op 1.08
fastMsgIdFn sha256 / 200 bytes 3.5790 us/op 3.3320 us/op 1.07
fastMsgIdFn h32 xxhash / 200 bytes 292.00 ns/op 272.00 ns/op 1.07
fastMsgIdFn h64 xxhash / 200 bytes 407.00 ns/op 375.00 ns/op 1.09
fastMsgIdFn sha256 / 1000 bytes 11.806 us/op 11.325 us/op 1.04
fastMsgIdFn h32 xxhash / 1000 bytes 425.00 ns/op 403.00 ns/op 1.05
fastMsgIdFn h64 xxhash / 1000 bytes 490.00 ns/op 444.00 ns/op 1.10
fastMsgIdFn sha256 / 10000 bytes 104.41 us/op 100.73 us/op 1.04
fastMsgIdFn h32 xxhash / 10000 bytes 1.9770 us/op 1.8450 us/op 1.07
fastMsgIdFn h64 xxhash / 10000 bytes 1.3920 us/op 1.2790 us/op 1.09
enrSubnets - fastDeserialize 64 bits 1.3740 us/op 1.2360 us/op 1.11
enrSubnets - ssz BitVector 64 bits 589.00 ns/op 459.00 ns/op 1.28
enrSubnets - fastDeserialize 4 bits 182.00 ns/op 160.00 ns/op 1.14
enrSubnets - ssz BitVector 4 bits 521.00 ns/op 478.00 ns/op 1.09
prioritizePeers score -10:0 att 32-0.1 sync 2-0 111.48 us/op 104.19 us/op 1.07
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 156.75 us/op 127.27 us/op 1.23
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 180.13 us/op 163.28 us/op 1.10
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 330.46 us/op 301.10 us/op 1.10
prioritizePeers score 0:0 att 64-1 sync 4-1 389.94 us/op 347.10 us/op 1.12
array of 16000 items push then shift 1.6830 us/op 1.5470 us/op 1.09
LinkedList of 16000 items push then shift 8.9760 ns/op 8.3660 ns/op 1.07
array of 16000 items push then pop 101.32 ns/op 73.759 ns/op 1.37
LinkedList of 16000 items push then pop 8.6830 ns/op 8.0890 ns/op 1.07
array of 24000 items push then shift 2.4241 us/op 2.2436 us/op 1.08
LinkedList of 24000 items push then shift 8.7770 ns/op 8.3700 ns/op 1.05
array of 24000 items push then pop 86.575 ns/op 72.860 ns/op 1.19
LinkedList of 24000 items push then pop 8.6260 ns/op 8.1220 ns/op 1.06
intersect bitArray bitLen 8 13.654 ns/op 12.698 ns/op 1.08
intersect array and set length 8 78.059 ns/op 73.733 ns/op 1.06
intersect bitArray bitLen 128 44.706 ns/op 42.095 ns/op 1.06
intersect array and set length 128 1.0495 us/op 1.0029 us/op 1.05
Buffer.concat 32 items 2.5970 us/op 2.8690 us/op 0.91
Uint8Array.set 32 items 2.9120 us/op 2.8310 us/op 1.03
pass gossip attestations to forkchoice per slot 3.0968 ms/op 2.6937 ms/op 1.15
computeDeltas 3.0210 ms/op 3.2391 ms/op 0.93
computeProposerBoostScoreFromBalances 1.8052 ms/op 1.7650 ms/op 1.02
altair processAttestation - 250000 vs - 7PWei normalcase 2.2291 ms/op 2.2279 ms/op 1.00
altair processAttestation - 250000 vs - 7PWei worstcase 3.4486 ms/op 3.6420 ms/op 0.95
altair processAttestation - setStatus - 1/6 committees join 146.66 us/op 143.19 us/op 1.02
altair processAttestation - setStatus - 1/3 committees join 276.29 us/op 280.22 us/op 0.99
altair processAttestation - setStatus - 1/2 committees join 377.05 us/op 373.49 us/op 1.01
altair processAttestation - setStatus - 2/3 committees join 462.05 us/op 461.95 us/op 1.00
altair processAttestation - setStatus - 4/5 committees join 672.67 us/op 653.16 us/op 1.03
altair processAttestation - setStatus - 100% committees join 767.22 us/op 757.24 us/op 1.01
altair processBlock - 250000 vs - 7PWei normalcase 17.599 ms/op 18.447 ms/op 0.95
altair processBlock - 250000 vs - 7PWei normalcase hashState 24.339 ms/op 25.932 ms/op 0.94
altair processBlock - 250000 vs - 7PWei worstcase 47.720 ms/op 52.179 ms/op 0.91
altair processBlock - 250000 vs - 7PWei worstcase hashState 67.717 ms/op 67.562 ms/op 1.00
phase0 processBlock - 250000 vs - 7PWei normalcase 2.2488 ms/op 2.2034 ms/op 1.02
phase0 processBlock - 250000 vs - 7PWei worstcase 29.680 ms/op 29.882 ms/op 0.99
altair processEth1Data - 250000 vs - 7PWei normalcase 495.94 us/op 529.52 us/op 0.94
vc - 250000 eb 1 eth1 1 we 0 wn 0 - smpl 15 7.9940 us/op 8.2940 us/op 0.96
vc - 250000 eb 0.95 eth1 0.1 we 0.05 wn 0 - smpl 219 25.545 us/op 26.927 us/op 0.95
vc - 250000 eb 0.95 eth1 0.3 we 0.05 wn 0 - smpl 42 9.3370 us/op 11.188 us/op 0.83
vc - 250000 eb 0.95 eth1 0.7 we 0.05 wn 0 - smpl 18 7.2160 us/op 8.4570 us/op 0.85
vc - 250000 eb 0.1 eth1 0.1 we 0 wn 0 - smpl 1020 95.760 us/op 99.509 us/op 0.96
vc - 250000 eb 0.03 eth1 0.03 we 0 wn 0 - smpl 11777 669.75 us/op 658.01 us/op 1.02
vc - 250000 eb 0.01 eth1 0.01 we 0 wn 0 - smpl 16384 909.68 us/op 918.66 us/op 0.99
vc - 250000 eb 0 eth1 0 we 0 wn 0 - smpl 16384 915.45 us/op 906.88 us/op 1.01
vc - 250000 eb 0 eth1 0 we 0 wn 0 nocache - smpl 16384 2.3620 ms/op 2.5046 ms/op 0.94
vc - 250000 eb 0 eth1 1 we 0 wn 0 - smpl 16384 1.5515 ms/op 1.5665 ms/op 0.99
vc - 250000 eb 0 eth1 1 we 0 wn 0 nocache - smpl 16384 3.8925 ms/op 4.0918 ms/op 0.95
Tree 40 250000 create 295.90 ms/op 387.86 ms/op 0.76
Tree 40 250000 get(125000) 179.33 ns/op 201.59 ns/op 0.89
Tree 40 250000 set(125000) 881.48 ns/op 939.25 ns/op 0.94
Tree 40 250000 toArray() 18.407 ms/op 22.956 ms/op 0.80
Tree 40 250000 iterate all - toArray() + loop 18.399 ms/op 21.874 ms/op 0.84
Tree 40 250000 iterate all - get(i) 67.717 ms/op 74.149 ms/op 0.91
MutableVector 250000 create 8.9155 ms/op 10.606 ms/op 0.84
MutableVector 250000 get(125000) 6.3230 ns/op 6.9210 ns/op 0.91
MutableVector 250000 set(125000) 261.19 ns/op 255.04 ns/op 1.02
MutableVector 250000 toArray() 2.7374 ms/op 3.5254 ms/op 0.78
MutableVector 250000 iterate all - toArray() + loop 2.8480 ms/op 3.5547 ms/op 0.80
MutableVector 250000 iterate all - get(i) 1.4983 ms/op 1.5610 ms/op 0.96
Array 250000 create 2.5440 ms/op 2.8978 ms/op 0.88
Array 250000 clone - spread 1.2360 ms/op 1.1546 ms/op 1.07
Array 250000 get(125000) 0.59600 ns/op 0.57100 ns/op 1.04
Array 250000 set(125000) 0.65600 ns/op 0.64700 ns/op 1.01
Array 250000 iterate all - loop 81.797 us/op 94.497 us/op 0.87
effectiveBalanceIncrements clone Uint8Array 300000 29.507 us/op 30.317 us/op 0.97
effectiveBalanceIncrements clone MutableVector 300000 406.00 ns/op 338.00 ns/op 1.20
effectiveBalanceIncrements rw all Uint8Array 300000 165.70 us/op 168.38 us/op 0.98
effectiveBalanceIncrements rw all MutableVector 300000 84.228 ms/op 79.430 ms/op 1.06
phase0 afterProcessEpoch - 250000 vs - 7PWei 113.15 ms/op 115.24 ms/op 0.98
phase0 beforeProcessEpoch - 250000 vs - 7PWei 41.767 ms/op 40.067 ms/op 1.04
altair processEpoch - mainnet_e81889 324.07 ms/op 295.79 ms/op 1.10
mainnet_e81889 - altair beforeProcessEpoch 66.911 ms/op 50.289 ms/op 1.33
mainnet_e81889 - altair processJustificationAndFinalization 16.322 us/op 17.940 us/op 0.91
mainnet_e81889 - altair processInactivityUpdates 5.3323 ms/op 5.5569 ms/op 0.96
mainnet_e81889 - altair processRewardsAndPenalties 65.507 ms/op 70.834 ms/op 0.92
mainnet_e81889 - altair processRegistryUpdates 2.3700 us/op 2.3340 us/op 1.02
mainnet_e81889 - altair processSlashings 463.00 ns/op 451.00 ns/op 1.03
mainnet_e81889 - altair processEth1DataReset 467.00 ns/op 464.00 ns/op 1.01
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.2396 ms/op 1.2477 ms/op 0.99
mainnet_e81889 - altair processSlashingsReset 4.4850 us/op 4.3430 us/op 1.03
mainnet_e81889 - altair processRandaoMixesReset 7.0470 us/op 5.7690 us/op 1.22
mainnet_e81889 - altair processHistoricalRootsUpdate 865.00 ns/op 674.00 ns/op 1.28
mainnet_e81889 - altair processParticipationFlagUpdates 2.2350 us/op 2.7830 us/op 0.80
mainnet_e81889 - altair processSyncCommitteeUpdates 479.00 ns/op 610.00 ns/op 0.79
mainnet_e81889 - altair afterProcessEpoch 125.13 ms/op 126.83 ms/op 0.99
phase0 processEpoch - mainnet_e58758 346.89 ms/op 352.17 ms/op 0.98
mainnet_e58758 - phase0 beforeProcessEpoch 110.53 ms/op 136.99 ms/op 0.81
mainnet_e58758 - phase0 processJustificationAndFinalization 18.278 us/op 23.756 us/op 0.77
mainnet_e58758 - phase0 processRewardsAndPenalties 52.772 ms/op 63.144 ms/op 0.84
mainnet_e58758 - phase0 processRegistryUpdates 8.0890 us/op 8.7830 us/op 0.92
mainnet_e58758 - phase0 processSlashings 480.00 ns/op 519.00 ns/op 0.92
mainnet_e58758 - phase0 processEth1DataReset 483.00 ns/op 804.00 ns/op 0.60
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.0036 ms/op 1.1123 ms/op 0.90
mainnet_e58758 - phase0 processSlashingsReset 3.9360 us/op 3.6690 us/op 1.07
mainnet_e58758 - phase0 processRandaoMixesReset 4.7920 us/op 4.7840 us/op 1.00
mainnet_e58758 - phase0 processHistoricalRootsUpdate 617.00 ns/op 611.00 ns/op 1.01
mainnet_e58758 - phase0 processParticipationRecordUpdates 4.2610 us/op 4.1110 us/op 1.04
mainnet_e58758 - phase0 afterProcessEpoch 97.664 ms/op 100.29 ms/op 0.97
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.2331 ms/op 1.2598 ms/op 0.98
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.8617 ms/op 1.5148 ms/op 1.23
altair processInactivityUpdates - 250000 normalcase 21.428 ms/op 26.644 ms/op 0.80
altair processInactivityUpdates - 250000 worstcase 23.671 ms/op 28.051 ms/op 0.84
phase0 processRegistryUpdates - 250000 normalcase 6.1170 us/op 6.6410 us/op 0.92
phase0 processRegistryUpdates - 250000 badcase_full_deposits 235.28 us/op 216.22 us/op 1.09
phase0 processRegistryUpdates - 250000 worstcase 0.5 103.42 ms/op 118.26 ms/op 0.87
altair processRewardsAndPenalties - 250000 normalcase 53.748 ms/op 66.574 ms/op 0.81
altair processRewardsAndPenalties - 250000 worstcase 51.197 ms/op 70.207 ms/op 0.73
phase0 getAttestationDeltas - 250000 normalcase 6.7273 ms/op 6.5894 ms/op 1.02
phase0 getAttestationDeltas - 250000 worstcase 6.7544 ms/op 6.5362 ms/op 1.03
phase0 processSlashings - 250000 worstcase 3.5612 ms/op 3.3369 ms/op 1.07
altair processSyncCommitteeUpdates - 250000 168.20 ms/op 171.01 ms/op 0.98
BeaconState.hashTreeRoot - No change 269.00 ns/op 259.00 ns/op 1.04
BeaconState.hashTreeRoot - 1 full validator 49.199 us/op 52.978 us/op 0.93
BeaconState.hashTreeRoot - 32 full validator 497.46 us/op 483.49 us/op 1.03
BeaconState.hashTreeRoot - 512 full validator 5.2962 ms/op 6.0717 ms/op 0.87
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 64.069 us/op 63.773 us/op 1.00
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 874.92 us/op 919.28 us/op 0.95
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 11.320 ms/op 11.420 ms/op 0.99
BeaconState.hashTreeRoot - 1 balances 48.352 us/op 50.333 us/op 0.96
BeaconState.hashTreeRoot - 32 balances 460.84 us/op 446.61 us/op 1.03
BeaconState.hashTreeRoot - 512 balances 4.2875 ms/op 4.1590 ms/op 1.03
BeaconState.hashTreeRoot - 250000 balances 74.568 ms/op 72.379 ms/op 1.03
aggregationBits - 2048 els - zipIndexesInBitList 16.280 us/op 15.664 us/op 1.04
regular array get 100000 times 32.855 us/op 31.040 us/op 1.06
wrappedArray get 100000 times 32.900 us/op 40.040 us/op 0.82
arrayWithProxy get 100000 times 15.836 ms/op 14.990 ms/op 1.06
ssz.Root.equals 556.00 ns/op 571.00 ns/op 0.97
byteArrayEquals 539.00 ns/op 523.00 ns/op 1.03
shuffle list - 16384 els 6.7929 ms/op 6.6444 ms/op 1.02
shuffle list - 250000 els 99.569 ms/op 97.365 ms/op 1.02
processSlot - 1 slots 8.5000 us/op 8.1240 us/op 1.05
processSlot - 32 slots 1.3096 ms/op 1.3548 ms/op 0.97
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 31.523 ms/op 36.849 ms/op 0.86
getCommitteeAssignments - req 1 vs - 250000 vc 2.9011 ms/op 2.8350 ms/op 1.02
getCommitteeAssignments - req 100 vs - 250000 vc 4.0886 ms/op 4.0190 ms/op 1.02
getCommitteeAssignments - req 1000 vs - 250000 vc 4.3345 ms/op 4.3471 ms/op 1.00
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.3700 ns/op 4.3500 ns/op 1.00
state getBlockRootAtSlot - 250000 vs - 7PWei 979.40 ns/op 980.28 ns/op 1.00
computeProposers - vc 250000 10.120 ms/op 10.590 ms/op 0.96
computeEpochShuffling - vc 250000 101.59 ms/op 101.64 ms/op 1.00
getNextSyncCommittee - vc 250000 164.41 ms/op 168.62 ms/op 0.98
computeSigningRoot for AttestationData 13.258 us/op 13.123 us/op 1.01
hash AttestationData serialized data then Buffer.toString(base64) 2.4957 us/op 2.3062 us/op 1.08
toHexString serialized data 1.1529 us/op 1.0478 us/op 1.10
Buffer.toString(base64) 338.00 ns/op 317.89 ns/op 1.06

by benchmarkbot/action

Comment thread tsconfig.json
Comment on lines +8 to +10
"noEmit": true,
// To be used in the test fixtures
"resolveJsonModule": true

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required to change here, because yarn lint on the repo is run with the top level config file, not the package specific.

import {validExecutionPayload} from "../../fixtures/cl_payload.js";
import {UNVERIFIED_RESPONSE_CODE} from "../../../src/constants.js";
import eth_getBalance_eoa from "../../fixtures/sepolia/eth_getBalance_eoa_proof.json" assert {type: "json"};
import eth_getBalance_contract from "../../fixtures/sepolia/eth_getBalance_contract_proof.json" assert {type: "json"};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import {writeFile, mkdir} from "node:fs/promises";
import path from "node:path";
import url from "node:url";
// eslint-disable-next-line import/no-extraneous-dependencies

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this disable necessary?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It requires to specify axios and few other packages as dependencies, while we just need it for development. So why had to disable this.

@wemeetagain wemeetagain left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@wemeetagain
wemeetagain merged commit c4ba9ff into unstable Apr 19, 2023
@wemeetagain
wemeetagain deleted the nh/prover-get-code branch April 19, 2023 13:23
@wemeetagain

Copy link
Copy Markdown
Member

馃帀 This PR is included in v1.8.0 馃帀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lodestar prover for execution api

3 participants